package com.reflex;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.Date;

public class Demo {
	
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		
		BaseDataDemo data = new BaseDataDemo();
		data.setName("李召");
		data.setAge(20);
		data.setTime(new Date());
		Class<BaseDataDemo> BaseDataDemoClass = (Class<BaseDataDemo>) data.getClass();
		Field[] fields = BaseDataDemoClass.getDeclaredFields();
		
		for(Field field:fields) {
			field.setAccessible(true);
			try {
				Annotation[] annotations =  field.getAnnotations();
				for(Annotation annotation:annotations) {
					if(annotation instanceof ExcelColumnName) {
						
						System.out.println(field.getName()+"的注释:"+((ExcelColumnName) annotation).value());
					}
				}
				System.out.println(field.getName() + ":" + field.get(data));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
	}

}
